home *** CD-ROM | disk | FTP | other *** search
/ Collection of Internet / Collection of Internet.iso / msdos / lynx / source / doslynx / src / turlwin4.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1994-10-25  |  4.8 KB  |  184 lines

  1. //    Copyright (c) 1993, University of Kansas, All Rights Reserved
  2. //
  3. //    Class:        TURLWindow
  4. //    Include File:    turlwind.h
  5. //    Purpose:    Provide a window for a URL
  6. //    Remarks/Portability/Dependencies/Restrictions:
  7. //    Revision History:
  8. //        12-27-93    created
  9. //        02-09-94    Split all members into seperate files.
  10. #define Uses_TProgram
  11. #define Uses_TDeskTop
  12. #include"turlwind.h"
  13. #include"trace.h"
  14.  
  15. void TURLWindow::handleEvent(TEvent& TE_event)    {
  16. //    Purpose:    Handle any events for the window.
  17. //    Arguments:    TE_event    The event occuring
  18. //    Return Value:    void
  19. //    Remarks/Portability/Dependencies/Restrictions:
  20. //    Revision History:
  21. //        01-21-94    created
  22.  
  23.     //    Command handler
  24.     if(TE_event.what & evMessage)    {
  25.         switch(TE_event.message.command)    {
  26.         case cmResize:
  27.         case cmZoom:
  28.         case cmTile:
  29.         case cmCascade:    {
  30.             //    Need to reload the URL if window chaned size.
  31.             TRect oldTR = getExtent();
  32.  
  33.             //    Have the base resize.
  34.             TWindow::handleEvent(TE_event);
  35.             clearEvent(TE_event);
  36.  
  37.             TRect TR = getExtent();
  38.  
  39.             //    Reload the url only if the view changed size.
  40.             if(TR.b.x != oldTR.b.x)    {
  41.                 //    First take out the last item in the
  42.                 //    history.  There will always be atleast
  43.                 //    one entry.  Assume the reload always
  44.                 //    works.
  45.                 auto char *cp_oldURL = (char *)
  46.                     (TNSCp_visited->at(TNSCp_visited->
  47.                     getCount() - 1));
  48.                 TNSCp_visited->remove(cp_oldURL);
  49.                 TNSCp_visited->pack();
  50.                 delete(cp_oldURL);
  51.  
  52.                 //    Reload.
  53.                 URLoader(TURLV->getURL());
  54.             }
  55.             break;
  56.         }
  57.         case cmLoadChild:    {
  58. #ifndef RELEASE
  59.             trace("loading child anchor.");
  60. #endif // RELEASE
  61.             clearEvent(TE_event);
  62.  
  63.             //    Get the child's name.
  64.             auto char *cp_childURL = TURLV->getChild();
  65.             if(cp_childURL == NULL)    {
  66.                 //    a valid child anchor not selected.
  67.                 doslynxmessage("Invalid selection.");
  68.                 delete(cp_childURL);
  69.                 break;
  70.             }
  71.  
  72.             //    Attempt the load.
  73.             URLoader(cp_childURL);
  74.             delete(cp_childURL);
  75.             break;
  76.         }
  77.         case cmClose:    {
  78. #ifndef RELEASE
  79.             trace("closing window.");
  80. #endif // RELEASE
  81.             destroy(TURLV);
  82.             TURLV = NULL;
  83.             break;
  84.         }
  85.         case cmLoadParent:    {
  86. #ifndef RELEASE
  87.             trace("loading previous document.");
  88. #endif // RELEASE
  89.             clearEvent(TE_event);
  90.  
  91.             //    Make sure there is a previous entry.
  92.             if(TNSCp_visited->getCount() <= 1)    {
  93.                 doslynxmessage("There are no previous "
  94.                     "documents.");
  95.                 break;
  96.             }
  97.  
  98.             //    Remove the last two names from the collection.
  99.             //    URLoader will replace the appropriate names.
  100.             auto char *cp_remove1, *cp_remove2;
  101.             cp_remove1 = (char *)(TNSCp_visited->at(
  102.                 TNSCp_visited->getCount() - 1));
  103.             TNSCp_visited->remove((void *)cp_remove1);
  104.             TNSCp_visited->pack();
  105.             cp_remove2 = (char *)(TNSCp_visited->at(
  106.                 TNSCp_visited->getCount() - 1));
  107.             TNSCp_visited->remove((void *)cp_remove2);
  108.             TNSCp_visited->pack();
  109.  
  110.             URLoader(cp_remove2);
  111.             delete(cp_remove1);
  112.             delete(cp_remove2);
  113.  
  114.             break;
  115.         }
  116.         case cmCloneWindow:    {
  117.             //    Get the name of the current url from our
  118.             //    history list.
  119.             auto char *cp_clone;
  120.             cp_clone = (char *)(TNSCp_visited->at(TNSCp_visited->
  121.                 getCount() - 1));
  122.  
  123.             //    Create our new valid window with our history.
  124.             TView *TV_new = TProgram::application->validView(
  125.                 (TView *)new TURLWindow(TNSCp_visited, cp_clone));
  126.  
  127.             //    If not created, don't insert onto the desktop.
  128.             //    Assume WWW produced appropriate error message.
  129.             if(TV_new != NULL)    {
  130.                 TProgram::deskTop->insert(TV_new);
  131.             }
  132.             break;
  133.         }
  134.         case cmSearchIndex:    {
  135.             //    Clear the event.
  136.             clearEvent(TE_event);
  137.  
  138.             //    First check to see if the current loaded view
  139.             //    is searchable.
  140.             if(B_isIndex == False)    {
  141.                 doslynxmessage("Not a searchable index.");
  142.                 break;
  143.             }
  144.  
  145.             //    Otherwise, do an index search.
  146.             IndexQuery();
  147.         }
  148.         case cmReceivedFocus:    {
  149.             //    See if we should enable the search index.
  150.             if(B_isIndex == True)    {
  151.                 enableCommand(cmSearchIndex);
  152.             }
  153.             break;
  154.         }
  155.         case cmAddToHist:    {
  156.             //    We should add the following to our visited
  157.             //    History.  This message used by view that
  158.             //    really doesn't want to reload but to go to
  159.             //    a tagged anchor within that document.
  160.             auto char *cp_toAdd = newStr((char *)TE_event.
  161.                 message.infoPtr);
  162.             TNSCp_visited->insert(cp_toAdd);
  163.             clearEvent(TE_event);
  164.             break;
  165.         }
  166.         }
  167.     }
  168.     else if(TE_event.what & evMouse)    {
  169.         //    A right button down will cause a copy of the current
  170.         //    window with the current document to be loaded.
  171.         if(TE_event.what == evMouseDown && TE_event.mouse.buttons ==
  172.             mbRightButton)    {
  173.             clearEvent(TE_event);
  174.             TEvent TE_clone;
  175.             TE_clone.what = evMessage;
  176.             TE_clone.message.command = cmCloneWindow;
  177.             TProgram::application->putEvent(TE_clone);
  178.         }
  179.     }
  180.  
  181.     //    Call the base event handler.
  182.     TWindow::handleEvent(TE_event);
  183. }
  184.